package com.alison;

import com.alison.config.Database;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.annotation.Import;
import org.springframework.context.annotation.PropertySource;

/**
 * @author wayne
 * @version PropertiesApp,  2020/1/29 9:15 下午
 */
//@EnableConfigurationProperties(value = {Database.class})
@Import(value = {Database.class})
//@PropertySource(name = "database.yaml", value = "classpath:database.yaml", encoding = "UTF-8", factory = YamlMapSourceFactory.class)
@SpringBootApplication
public class PropertiesApp implements ApplicationRunner {

    public static void main(String[] args) {
        ConfigurableApplicationContext run = SpringApplication.run(PropertiesApp.class, args);

        run.close();

    }

    @Autowired
    private Database database;

    @Override
    public void run(ApplicationArguments args) throws Exception {
        System.out.println(database);
//        assert database.getUrl() != null;
    }
}
